package structuralPattern.singletonPattern;
// 饿汉模式、线程安全、防止序列化和反射破解
public class StarvingPattern {
    private static StarvingPattern instance = new StarvingPattern();
    private StarvingPattern(){
        if (null != instance){
            throw new RuntimeException("反射失败");
        }
    }
    public static StarvingPattern getInstance(){
        return instance;
    }
    public StarvingPattern readResolve() throws RuntimeException{
        return instance;
    }
}
